<?php
namespace Admin\Controller;
use Think\Controller;
require "./Application/Admin/Common/Common/function.php";
class IndexController extends Controller {

    public function _initialize() {
        if (empty($_SESSION['user'])) {
           $this->error('请登入',U('Admin/Login/login'));
        }
    }

    public function index(){   
        $m = M('User');      
        $count = $m->count();
        $p = getpage($count);
        $list = $m->field(true)->where($where)->order('id')->limit($p->firstRow, $p->listRows)->select();
        $this->assign('str1', $list); // 赋值数据集
        $this->assign('page', $p->show()); // 赋值分页输出
        $this->display();
    }



    public function edit(){
      $id = I('get.id');
      $str = M('user') ->where('id='.$id)->find();
      $this->assign('str',$str);
      $this->display();

    }


    public function edit_do(){
      $id = I('post.id');
      $username=I('POST.username');
      $password=I('POST.password');
      $email=I('POST.email');
      $phone=I('POST.phone');
      $date=I('POST.date');
      $regtime = strtotime($date); 
      $data=array(
        'username'=>$username,
        'password'=>$password,
        'email'=>$email,
        'phone'=>$phone,
        'username'=>$username,
        'regtime'=>$regtime,
        );
      if(M('user')->where('id='.$id)->save($data)){

        $this->success('修改成功',U('Admin/Index/index'));

      }else{
        $this->error('修改失败');
      }
      

    }



     public function dele(){
       $id = I('get.id');
     
       if(M('user')->where('id='.$id)->delete()){
        $this->success('删除成功',U('Admin/Index/index'));
      }else{
        $this->error('删除失败');
      }
      
  

  
  

    }

}